<template>
  <div>
     <div>
         <span>手机号：</span>
         <input type="text" v-model="phone">
     </div>
     <div>
         <span>密码：</span>
         <input type="text" v-model="password">
     </div>
     <button @click="goToLogin">登录</button>
  </div>
</template>

<script>
import {login} from "../../api/api"
export default {
    data(){
      return {
         phone:"",
         password:"",
      }
    },
    methods:{
      async goToLogin(){
         let {phone,password}=this;
         try{
             let res=await login({
               phone,
               password
             })
             if(res.status==200){
               location.setItem("token",res.data.data.token)
             }
         }catch(error){
             alert(error.response.data.msg)
         }
      }
    }
}
</script>

<style>

</style>